package com.trademark.script.methods;

import com.rsbuddy.script.methods.Mouse;
import com.rsbuddy.script.methods.Widgets;
import com.rsbuddy.script.task.Task;
import com.rsbuddy.script.wrappers.Component;

public class Emotes {

	public final static int YES = 0, NO = 1, CURTSY_BOW = 2, ANGRY = 3,
			THINK = 4, WAVE = 5, SHRUG = 6, CHEER = 7, BECKON = 8, LAUGH = 9,
			JUMP_FOR_JOY = 10, YAWN = 11, DANCE = 12, JIG = 13, TWIRL = 14,
			HEADBANG = 15, CRY = 16, BLOW_KISS = 17, PANIC = 18,
			RASPBERRY = 19, CLAP = 20, SALUTE = 21, GOBLIN_BOW = 22,
			GOBLIN_SALUTE = 23, GLASS_BOX = 24, CLIMB_ROPE = 25, LEAN = 26,
			GLASS_WALL = 27, IDEA = 28, STOMP = 29, FLAP = 30, SLAP_HEAD = 31,
			ZOMBIE_WALK = 32, ZOMBIE_DANCE = 33, ZOMBIE_HAND = 34, SCARED = 35,
			BUNNY_HOP = 36, SKILLCAPE = 37, SNOWMAN_DANCE = 38,
			AIR_GUITAR = 39, SAFETY_FIRST = 40, EXPLORE = 41, TRICK = 42,
			FREEZE = 43, GIVE_THANKS = 44, AROUND_THE_WORLD_IN_EGGTY_DAYS = 45,
			DRAMATIC_POINT = 46, FAINT = 47, PUPPET_MASTER = 48,
			TASKMASTER = 49, SEAL_OF_APPROVAL = 50, CAT_FIGHT = 51,
			TALK_TO_THE_HAND = 52, SHAKE_HANDS = 53, HIGH_FIVE = 54,
			FACE_PALM = 55, SURRENDER = 56, LEVITATE = 57,
			MUSCLE_MAN_POSE = 58, ROFL = 59, BREATHE_FIRE = 60, STORM = 61,
			SNOW = 62, INVOKE_SPRING = 63, HEAD_IN_THE_SAND = 64,
			HULA_HOOP = 65, DISAPPEAR = 66, GHOST = 67, BRING_IT = 68,
			PALM_FIST = 69, KNEEL = 70, BEGGING = 71, STIR_CAULDRON = 72,
			CHEER_TWO = 73, TANTRUM = 74, DRAMATIC_DEATH = 75,
			JUMP_AND_YELL = 76, POINT = 77, PUNCH = 78, RAISE_HAND = 79,
			MAKE_SPEECH = 80, SWORD_FIGHT = 81, RAISE_HAND_SITTING = 82,
			WAVE_SITTING = 83, CHEER_SITTING = 84, THROW_TOMATO_SITTING = 85,
			THROW_FLOWERS_SITTING = 86, AGREE_SITTING = 87, POINT_SITTING = 88,
			WHISTLE_SITTING = 89, THUMBS_UP_SITTING = 90,
			THUMBS_DOWN_SITTING = 91, CLAP_SITTING = 92;

	/*
	 * @param id The component's component id of the emote
	 */
	public static Component getEmote(final int id) {
		return Widgets.get(590).getComponent(8).getComponent(id);
	}

	/*
	 * @param id The component's component id of the emote
	 * 
	 * @return Returns true if the emote is valid; otherwise returns false
	 */
	public static boolean isValid(final int id) {
		return getEmote(id) != null;
	}

	/*
	 * @param id The component's component to be checked if it's showing
	 * 
	 * @return Returns true if the emote is showing within the boundaries;
	 * otherwise returns false
	 */
	public static boolean isShowing(final int id) {
		return Widgets
				.get(590)
				.getComponent(8)
				.contains(
						Widgets.get(590).getComponent(8).getComponent(id)
								.getAbsLocation());
	}

	/*
	 * @param id The component's component to be scrolled to
	 */
	public static void scrollToEmote(final int id) {
		if (!isShowing(id)) {
			if (Widgets.get(590).getComponent(8).getComponent(id)
					.getAbsoluteY() > Widgets.get(590).getComponent(8)
					.getAbsoluteY()) {
				Mouse.scroll(false);
				Task.sleep(300, 400);
			} else {
				Mouse.scroll(true);
				Task.sleep(300, 400);
			}
		}
	}

	/*
	 * @param id The component's component to be performed
	 * 
	 * @param action The string action to be used for the emote
	 */
	public static void performEmote(final int id, final String action) {
		if (!isShowing(id)) {
			scrollToEmote(id);
			Task.sleep(300, 400);
		} else {
			Widgets.get(590).getComponent(8).getComponent(id).interact(action);
		}
	}
}
